home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 35
/
PC Gamer IT CD 35 1-2.iso
/
Elink
/
NSCOMM
/
NCJS10.JAR
/
vscroll.js
< prev
next >
Wrap
Text File
|
1997-10-20
|
3KB
|
120 lines
<!-- scrolling layers: vertical tab scrolling -->
<!-- Author: Tom Pixley -->
<!-- Adaptation: Kyle Sims -->
<!-- Math: Michael Plitkins, Greg Scallan -->
<!-- Modified: 6-26-97 -->
var DRAG_Y, DRAG_lastY, DRAG_dragging;
var verticalDragDelta = 0;
var tabOffset = 0;
var tabPosition = 0;
var previousTabPosition = 0;
var direction = "down";
function DRAG_begindrag(e) {
if (e.which == 1) {
document.captureEvents(Event.MOUSEMOVE);
DRAG_lastY=e.pageY;
DRAG_dragging=true;
return false;
}
else {
/*Do any right mouse button processing here*/
return true;
}
}
function DRAG_enddrag(e) {
if (e.which == 1) {
document.releaseEvents(Event.MOUSEMOVE);
DRAG_dragging=false;
return false;
}
else {
/*Do any right mouse button processing here*/
return true;
}
}
function DRAG_drag(e) {
if (DRAG_dragging) {
/*This function should only be called if MOUSEMOVEs are captured*/
DRAG_Y = e.pageY;
setPreviousTabPosition(DRAG_Y);
DRAG_lastY=e.pageY;
//scroll content area in increments on mousedrag
snapContent(direction);
return false;
}
else {
return true;
}
}
function recalcTabOffset(Y) {
//normalize the tab position (negate the length of the tab)
tabOffset = Y - vTabY;
}
function recalcTabPosition(Y, vTabTopLimit) {
tabPosition = ((Y - vTabTopLimit) - tabOffset) / (vTabRange);
}
function setPreviousTabPosition(Y) {
previousTabPosition = tabPosition;
//determine scrolling direction based on MOUSE position
if(DRAG_Y < DRAG_lastY) direction = "up";
else if(DRAG_Y > DRAG_lastY) direction = "down";
}
function recalcVerticalDragDelta() {
//get the delta of the previous and current mouse positions
verticalDragDelta = (tabPosition - previousTabPosition);
}
function recalcContentY() {
//calculate the new position of the content area layer
contentY = vddMultiplier * verticalDragDelta;
//convert the new content area layer position to a negative value
contentY = 0 - contentY;
}
function checkTabBounds(Y, vTabTopLimit) {
//if the tab position is not in bounds
if(tabPosition < 0 || tabPosition > 1) {
if(tabPosition < 0) {
tabPosition = 0;
moveTo(verticalTabLayer.left, vTabTopLimit);
}
else if(tabPosition > 1) {
tabPosition = 1;
moveTo(verticalTabLayer.left, (vTabBottomLimit - vTabH));
}
}
//if the tab position is in bounds
else {
moveBy(0, Y);
}
}
/*If you want links to work, capture MouseDown and MouseUp separately*/
document.onmousedown=DRAG_begindrag;
document.onmouseup=DRAG_enddrag;
document.onmousemove=DRAG_drag;